import React, { Component } from 'react'
import { connect } from 'react-redux'
import { add } from '../redux/actions/count'

class FinalCounter extends Component {
    render() {
        return (
            <div>
                <h2>当前求和为：{this.props.count}</h2>
                <button onClick={this.add}>+3</button>
                <h2>总{this.props.personCount}人</h2>
            </div>
        )
    }
    add = () => {
        this.props.add(3)
    }
}
const container = connect(
    ({ count, persons }) => {
        return { count, personCount: persons.length }
    },
    {
        add
    }
)(FinalCounter)
export default container